home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 001 / pibt40s1.arc / GETFSIZE.MOD < prev    next >
Text File  |  1986-06-17  |  3KB  |  65 lines

  1. (*----------------------------------------------------------------------*)
  2. (*           Get_File_Size --- Get size in bytes for a file             *)
  3. (*----------------------------------------------------------------------*)
  4.  
  5. FUNCTION Get_File_Size( Fname: AnyStr; VAR OpenOK : BOOLEAN ): REAL;
  6.  
  7. (*----------------------------------------------------------------------*)
  8. (*                                                                      *)
  9. (*     Procedure:  Get_File_Size                                        *)
  10. (*                                                                      *)
  11. (*     Purpose:    Get size in bytes for a file                         *)
  12. (*                                                                      *)
  13. (*     Calling Sequence:                                                *)
  14. (*                                                                      *)
  15. (*        Fsize := Get_File_Size( Fname      : AnyStr;                  *)
  16. (*                                VAR OpenOK : BOOLEAN ) : REAL;        *)
  17. (*                                                                      *)
  18. (*           Fname  --- name of file to find size of                    *)
  19. (*           OpenOK --- set TRUE if file opened successfully            *)
  20. (*           Fsize  --- file size in bytes                              *)
  21. (*                                                                      *)
  22. (*     Calls:                                                           *)
  23. (*                                                                      *)
  24. (*        RESET                                                         *)
  25. (*        Int24Result                                                   *)
  26. (*        ASSIGN                                                        *)
  27. (*        LongFileSize                                                  *)
  28. (*        Close                                                         *)
  29. (*                                                                      *)
  30. (*     Remarks:                                                         *)
  31. (*                                                                      *)
  32. (*        The file must not already be opened before calling this       *)
  33. (*        routine.                                                      *)
  34. (*                                                                      *)
  35. (*----------------------------------------------------------------------*)
  36.  
  37. VAR
  38.    F : FILE OF BYTE;
  39.    I : INTEGER;
  40.  
  41. BEGIN (* Get_File_Size *)
  42.  
  43.    Get_File_Size := 0.0;
  44.  
  45.    ASSIGN( F , Fname );
  46.    (*$I- *)
  47.    RESET ( F );
  48.    (*$I+ *)
  49.  
  50.    IF Int24Result = 0 THEN
  51.       BEGIN
  52.          Get_File_Size := LongFileSize( F );
  53.          OpenOK := TRUE;
  54.       END
  55.    ELSE
  56.       OpenOK := FALSE;
  57.  
  58.       (*$I-*)
  59.    CLOSE( F );
  60.       (*$I+*)
  61.  
  62.    I := INT24Result;
  63.  
  64. END   (* Get_File_Size *);
  65.